package 第一讲基础算法;

import java.util.Scanner;

public class AcWing798 {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int q=sc.nextInt();
		int N=1010;
		int[][] a=new int[N][N];
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=m;j++) {
				a[i][j]=sc.nextInt();
			}
		}
		int[][] diff=new int[N][N];
		//构建差分数组
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=m;j++) {
				add(diff,i,j,i,j,a[i][j]);
			}
		}
		while(q-->0) {
			int x1=sc.nextInt();
			int y1=sc.nextInt();
			int x2=sc.nextInt();
			int y2=sc.nextInt();
			int c=sc.nextInt();
			add(diff,x1,y1,x2,y2,c);
		}
		
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=m;j++) {
				diff[i][j]+=diff[i-1][j]+diff[i][j-1]-diff[i-1][j-1];
			
			}
		}
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=m;j++) {
				System.out.print(diff[i][j]+" ");
			}
			System.out.println();
		}
		sc.close();
		
		
	}
	
	public static void add(int[][] diff,int x1,int y1,int x2,int y2,int c) {
		diff[x1][y1]+=c;
		diff[x2+1][y1]-=c;
		diff[x1][y2+1]-=c;
		diff[x2+1][y2+1]+=c;
	}

}
